Skip to content

OLMIS-8249: Mark invalid adjustment quantity fields#89

Open
denys1204 wants to merge 2 commits into
masterfrom
OLMIS-8249-mark-invalid-adjustment-lines
Open

OLMIS-8249: Mark invalid adjustment quantity fields#89
denys1204 wants to merge 2 commits into
masterfrom
OLMIS-8249-mark-invalid-adjustment-lines

Conversation

@denys1204

Copy link
Copy Markdown
Contributor

Problem

Reasons whose quantity is not greater than 0 (zero or empty) block the physical
inventory update, but the offending fields in the "Reasons for …" modal were not
marked — so the user got the "Quantity must be greater than 0" alert without any
indication of which line was blocking them.

Changes

  • Expose hasValidQuantity on AdjustmentsModalController.
  • Add a quantity-invalid class to an adjustment row (editable mode only) when its
    quantity is not greater than 0.
  • Render the invalid state on the whole quantity field (the .input-control wrapper),
    matching how the required Reason field is marked. The selector targets the wrapper
    <div> only — a bare .input-control also matches the inner <input> (which
    @extends .input-control) and would paint a second, nested border.
  • Works in both the Packs and the Doses view.

Files changed (4): adjustments-modal.controller.js, adjustments-modal.html,
_adjustments-modal.scss, adjustments-modal.controller.spec.js.

Testing

  • grunt test — all unit tests pass (964/964), including new hasValidQuantity specs.
  • grunt eslint — clean (no new issues).
  • Built ui-components + reference-ui locally and verified the highlight in the
    physical inventory adjustments modal (Packs and Doses).

Screenshot

image

Reasons whose quantity is not greater than 0 block the physical inventory
update, but the offending fields were not marked, so users could not tell
which line was blocking them.

Expose hasValidQuantity on the AdjustmentsModalController and add a
quantity-invalid class to an adjustment row when its quantity is not greater
than 0. The invalid state is rendered on the whole quantity field (the
.input-control wrapper), matching how the Reason field is marked. The selector
targets the wrapper <div> only: a bare .input-control also matches the inner
<input> (which @extends .input-control) and would paint a second, nested
border.

Covered by new AdjustmentsModalController hasValidQuantity specs.
@kszymankiewicz-sd

Copy link
Copy Markdown
Contributor

Generally the solution looks good but I'd propose reusing the existing styles. This proposition introduces another invalid style that is only used for adjustments modal but the FE already has such styles / directives that can be reused. Try to work with openlmis-invalid attribute or with is-invalid class (or both). I suppose the openlmis-quantity-unit-input might be problematic so please review briefly if the invalid styles are wired to this directive or can be easily wired (packs&doses are currently in improvement stage so maybe it would be great to propose some enhancements).
Generally I'd like to reuse existing mechanisms instead of implementing new ones.

Per review, replace the bespoke invalid style with the platform's existing
openlmis-invalid mechanism, the same pattern used by stock-add-products-modal.

- Drop the module-scoped SCSS rule and the custom quantity-invalid class.
- validateAdjustment stores a quantityInvalid message on an adjustment whose
  quantity is not greater than 0; it runs on quantity change and for every row
  on save.
- Mark the quantity cell with openlmis-invalid, and broadcast
  openlmis-form-submit on save so the messages are revealed.

No custom CSS. Works in both the Packs and the Doses view. Specs updated to
cover validateAdjustment and save marking.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants